//
//  YZWorkNoteModel.m
//  VET
//
//  Created by 刘文靖 on 2018/7/10.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZWorkNoteModel.h"
#import "MJExtension.h"
#import "YZAutoItemModel.h"
#import "YZPigModel.h"
#import "YZSwineryModel.h"
@implementation YZArchiveModel
+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{@"number" : @"vetArchiveObjectInfoVo.number",
             @"sex":@"vetArchiveObjectInfoVo.sex",
             @"status":@"vetArchiveObjectInfoVo.status",
             @"type":@"vetArchiveObjectInfoVo.type",
             @"species":@"vetArchiveObjectInfoVo.species"
             };
}

- (NSString *)archiveStr{
    if ([self.archiveType isEqualToString:@"swine"]) {
        return [NSString stringWithFormat:@"猪只%@",self.number];
    }else{
        return [NSString stringWithFormat:@"猪群%@",self.number];
    }
}
- (NSString *)optionStr{
    if ([self.archiveType isEqualToString:@"swine"]) {
        return [NSString stringWithFormat:@"猪只%@ (%@ %@ %@)",self.number,self.type.itemValue?:@"",self.sex.itemValue?:@"",self.status.itemValue?:@"未确定"];
    }else{
        return [NSString stringWithFormat:@"猪群%@ (%@ %@)",self.number,self.type.itemValue?:@"",self.status.itemValue?:@"未确定"];
    }
}

+ (YZArchiveModel *)convertWithPig:(YZPigModel *)pig{
    YZArchiveModel *archive = [[YZArchiveModel alloc] init];
    archive.archiveId = pig.pigId;
    archive.archiveType = @"swine";
    archive.number = pig.earMark;
    archive.sex = pig.swineSex;
    archive.status = pig.swineState;
    archive.type = pig.swineClass;
    archive.species = pig.swineSpecies;
    return archive;
}
+ (YZArchiveModel *)convertWithSwinery:(YZSwineryModel *)swinery{
    YZArchiveModel *archive = [[YZArchiveModel alloc] init];
    archive.archiveId = swinery.swineryId;
    archive.archiveType = @"herd";
    archive.number = swinery.batchNo;
    archive.type = swinery.herdClass;
    archive.status = swinery.herdState;
    archive.realQty = swinery.realQty;
    return archive;
}
@end

@implementation YZAttachmentModel
- (NSURL *)url{
    if ([self.mediaType isEqualToString:@"video/mp4"]) {
        return [NSURL URLWithString:[NSString stringWithFormat:@"%@?x-oss-process=video/snapshot,t_1000,w_400,h_0,m_fast,f_jpg",self.attachmentUrl]];
    }
    return [NSURL URLWithString:self.attachmentUrl];
}

@end
@implementation YZWorkNoteModel
+ (NSDictionary *)mj_objectClassInArray
{
    return @{
             @"attachmentList"  : @"YZAttachmentModel",
             @"archiveList"  : @"YZArchiveModel"
             };
}

+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{@"noteId" : @"id",
             @"createTime":@"gmtCreated"
             };
}

- (YZWorkNoteAttachType)attachType{
    YZAttachmentModel *attach = self.attachmentList.firstObject;
    if ([attach.mediaType isEqualToString:@"video/mp4"]) {
        return YZWorkNoteAttachTypeVideo;
    }else if ([attach.mediaType isEqualToString:@"audio/aac"]){
        return YZWorkNoteAttachTypeAudio;
    }
    return YZWorkNoteAttachTypeImage;
}

@end
